package com.seeyon.ctp.rest.resources;

import com.seeyon.apps.quartz.form.QuartzFormFieldEnum;
import com.seeyon.apps.quartz.job.UpdateRecordJob;
import com.seeyon.apps.quartz.util.CAP4FormKit;
import com.seeyon.apps.quartz.util.QsQuartzUtil;
import com.seeyon.cap4.form.api.FormApi4Cap4;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.log.CtpLogFactory;
import com.seeyon.ctp.util.annotation.RestInterfaceAnnotation;
import org.apache.commons.logging.Log;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;

/**
 * @Author: SPK
 * @Date: 2022/7/6 14:30
 * @Description:手动刷新功能
 */
@Path("leaveRecord")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class LeaveRecordResource extends BaseResource {
    private static final Log log = CtpLogFactory.getLog(LeaveRecordResource.class);
    private FormApi4Cap4 formApi4Cap4;
    private FormBean form;


    /**
     * 手动刷新档案
     * @param param
     * @return
     */
    @POST
    @Path("refresh")
    @RestInterfaceAnnotation(OpenExternal = RestInterfaceAnnotation.External.NO, StartVersion = "V7.0")
    public Response refresh(Map<String, String> param) {
        UpdateRecordJob updateRecordJob = new UpdateRecordJob();
        if(UpdateRecordJob.isOn()){
            return fail("当前正在执行刷新");
        }
        try {
            updateRecordJob.taskRun("");
        } catch (Exception e) {
            log.info("手动刷新考勤档案失败");
            return fail("手动刷新考勤档案失败");
        }
        return success("手动刷新考勤档案成功");
    }

}
